sed 行首行尾追加内容

sed 行首行尾追加内容

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
在每行的头添加字符,比如"HEAD",命令如下:

sed 's/^/HEAD&/g' test.file
在每行的行尾添加字符,比如“TAIL”,命令如下:

sed 's/$/&TAIL/g' test.file

在字符串"alone"结尾的行,后追加ffing
sed 's/alone$/&ffing/g' test.file

在字符串"alone"开头的行,后追加ffing
sed 's/^alone.*/&ffing/g' test.file